/** 
* @param {array}
* @param {function}
* @param {any}
* @returns {boolean}
**/
function reduce(array, callback, initValue) {
  if (!Array.isArray(array)) return
  const len = array.length
  let i = -1
  let value = initValue ? initValue : array[++i]

  while(++i < len) {
    value = callback(value, array[i], i, array)
  }
  return value
}

export default reduce